//
//  BaseTabBarViewController.m
//  GiftItems
//
//  Created by lanou3g on 15/9/18.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "BaseTabBarViewController.h"
#import "ClassViewController.h"
#import "MainTableViewController.h"
#import "MineTableViewController.h"
#import "HotSellerTableViewController.h"
@interface BaseTabBarViewController ()

@end

@implementation BaseTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBar.tintColor = kRGB(255.0, 100.0, 255.0);
    
    MainTableViewController *mainVC = [[MainTableViewController alloc] initWithStyle:(UITableViewStylePlain)];
    [self addChildVC:mainVC title:@"首页" imageName:@"bottom_home_icon@2x" selectedImage:@""];
    HotSellerTableViewController *hotVC = [[HotSellerTableViewController alloc] initWithStyle:(UITableViewStylePlain)];
    [self addChildVC:hotVC title:@"热卖" imageName:@"bottom_clothes_icon@2x" selectedImage:@""];
    
    ClassViewController *classVC = [[ClassViewController alloc] init];
    [self addChildVC:classVC title:@"分类" imageName:@"bottom_sort_icon@2x" selectedImage:@""];
    
    
    MineTableViewController *mineVC = [[MineTableViewController alloc] init];
    [self addChildVC:mineVC title:@"我的" imageName:@"bottom_like_icon@2x" selectedImage:@""];



}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


- (void)addChildVC:(UIViewController *)childVC title:(NSString *)title imageName:(NSString *)imageName selectedImage:(NSString *)selectedIamge {
    // 设置默认图标
    childVC.tabBarItem.image = [UIImage imageNamed:imageName];
    // 设置选中图标
    childVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedIamge] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    // 设置导航控制器
    UINavigationController *childNVC = [[UINavigationController alloc] initWithRootViewController:childVC];
    

    childNVC.tabBarItem.title = title;
    childNVC.navigationBar.barTintColor = [UIColor colorWithRed:255.0 / 255 green:151.0 / 255 blue:255.0 / 255 alpha:1.0];
    childNVC.navigationBar.translucent = NO; 
    if ([title isEqualToString:@"分类"]) {
        childVC.navigationController.title = @"";
    }else if([title isEqualToString:@"首页"]){
        childVC.navigationItem.title = @"优礼";
    }else {
        childVC.navigationItem.title = title;
    }
    [self addChildViewController:childNVC];
    
}



@end
